<!-- 查看 -->
<template>
  <view class="box">
    <Header title="查看" />
    <view class="top-tab">
      <view v-for="(item, index) in tabData" :key="index" @click="checkTab(item.value)">
        <uv-line class="line" v-if="index !== 0" color="#C0C4CC"></uv-line>
        <view class="label" :class="selectTab == item.value ? 'action' : 'noAction'" >{{ item.name }}</view>
        <uv-line class="line" v-if="index !== tabData.length - 1" color="#C0C4CC"></uv-line>
      </view>
    </view>
    <view class="box-content">
      <!-- 基本信息 -->
      <basicInformation v-if="selectTab == 0 && law.schoolId" :schoolId="law.schoolId"  :canteenId="law.canteenId"></basicInformation>
      <!--检查信息 -->
      <view v-if="selectTab == 1">
        <checkTheInformation :lawItem="checkInformation" :law="law"></checkTheInformation>
      </view>
      <!-- 整改信息 -->
      <view v-if="selectTab == 2">
        <rectificationInformation :data="rectifyInformation" :entryType="entryType"/>
      </view>
      <!-- 复查信息 -->
      <view v-if="selectTab == 3">
        <reviewTheInformation :data="reviewInformation"/>
      </view>
    </view>
  </view>
</template>

<script setup>
import basicInformation from '@/packageSelfInspection/pages/viewInfo/basicInformation.vue';
import checkTheInformation from '@/packageSelfInspection/pages/viewInfo/checkTheInformation.vue';
import rectificationInformation from '@/packageSelfInspection/pages/viewInfo/rectificationInformation.vue';
import reviewTheInformation from '@/packageSelfInspection/pages/viewInfo/reviewTheInformation.vue';
import {reactive,ref,getCurrentInstance} from "vue";
let {proxy} = getCurrentInstance();
import { onLoad } from '@dcloudio/uni-app';
import api from "@/api/law/supLaw/supLaw";

let tabData = ref([
  { name: '基本信息', value: 0 }
]);
let law =ref({});
// 检查信息
let checkInformation = ref({});
// 整改信息
let rectifyInformation = ref({});
// 复查信息
let reviewInformation = ref({});

let selectTab = ref(0);

let entryType = ref(0);



let getData = (id) =>{
  proxy.http.get(api.getInfo(id)).then(res => {
    if(res.code === 0) {
      let data = res.data
      if (data.params.hasOwnProperty("10")) {
        law.value = data;
        checkInformation.value = data.params["10"];
        tabData.value.push({name: '检查信息', value: 1});
        selectTab.value = 1;
      }
      if (data.params.hasOwnProperty("20")) {
        rectifyInformation.value = data.params["20"];
        tabData.value.push({name: '整改信息', value: 2});
        selectTab.value = 2;
      }
      if (data.params.hasOwnProperty("40")) {
        reviewInformation.value = data.params["40"];
        tabData.value.push({name: '复查信息', value: 3});
        selectTab.value = 3;
      }
      entryType.value=data.entryType
    }
  })
};
onLoad((option) => {
  getData(option.id)
});

// tab选择
const checkTab = (e) => {
  selectTab.value = e
};
</script>

<style lang="scss" scoped>
@import "@/static/css/dailycheck/viewIndex.scss";
.box {
  display: flex;
  height: 100vh;
  min-height: 0;
  flex-direction: column;
}
::v-deep.uv-textarea__field {
  text-align: left !important;
  padding: 10rpx;
}

::v-deep .speech-main {
  .content {
    .uv-textarea__field {
      text-align: left !important;
      height: 400px !important;
    }

    .uv-border {
      border: 0 !important;
    }
  }
}

.top-tab {
  display: flex;
  justify-content: space-around;
  line-height: 50rpx;

  &>view {
    display: flex;
    flex:1;
    .label {
      margin-top: 30rpx;
      padding: 0 18rpx;
      font-size: var(--uni-font-size-14);
      flex-shrink: 0;
      color: #767676;
      &.action {
        color: #0256ff;
      }
    }
  }
}
.box-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
</style>
